package com.rentplant.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.order;
import com.rentplant.Pojo.orderanditem;
import com.rentplant.Pojo.outrentuserinfo;
import com.rentplant.mapper.orderMapper;
import com.rentplant.service.orderService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service //让他知道这是service
public class orderServiceImp implements orderService {

    @Autowired
    private orderMapper ordermapper;


//    付款生成待发货订单
    @Override
    public boolean payOrder(JSONObject orderinfo){
        return ordermapper.payOrder(orderinfo);
    }

    //    未付款生成待付款订单
    @Override
    public boolean noPayOrder(JSONObject orderinfo){
        return ordermapper.noPayOrder(orderinfo);
    }


    //    查找用户全部订单
    @Override
    public List<orderanditem> selectAllOrderById(JSONObject orderinfo){
        return ordermapper.selectAllOrderById(orderinfo);
    }


    //    查找该用户的未付款订单
    @Override
    public List<order> selectOrderNoPay(JSONObject orderinfo){
        return ordermapper.selectOrderNoPay(orderinfo);
    }

    //    查找该用户的待收货订单
    @Override
    public List<order> selectOrderWaitItem(JSONObject orderinfo){
        return ordermapper.selectOrderWaitItem(orderinfo);
    }
    //查找自己出售物品的订单
    @Override
    public List<orderanditem> otherOrderWaitItem(JSONObject orderinfo){
        return ordermapper.otherOrderWaitItem(orderinfo);
    }

    //    查找租用中订单
    @Override
    public List<order> selectOrderInRent(JSONObject orderinfo){
        return ordermapper.selectOrderInRent(orderinfo);
    }

    //    查找待归还订单
    @Override
    public  List<order> selectOrderBack(JSONObject orderinfo){
        return ordermapper.selectOrderBack(orderinfo);
    }

    //查找已完成和已评价订单
    @Override
    public  List<order> selectOrderFinish(JSONObject orderinfo){
        return ordermapper.selectOrderFinish(orderinfo);
    }


    //    查找待付款订单
    @Override
    public List<orderanditem> userOrderNoPay(JSONObject orderinfo){
        return ordermapper.userOrderNoPay(orderinfo);
    }

    //    查找待发货订单
    @Override
    public List<orderanditem> userOrderWaitItem(JSONObject orderinfo){
        return ordermapper.userOrderWaitItem(orderinfo);
    }

    //    查找租用中订单
    @Override
    public List<orderanditem> userOrderInRent(JSONObject orderinfo){
        return ordermapper.userOrderInRent(orderinfo);
    }

    //    查找待归还订单
    @Override
    public List<orderanditem> userOrderBack(JSONObject orderinfo){
        return ordermapper.userOrderBack(orderinfo);
    }

    //    查找已完成订单
    @Override
    public  List<orderanditem> userOrderFinish(JSONObject orderinfo){
        return ordermapper.userOrderFinish(orderinfo);
    }


    //    按照orderid查询订单
    @Override
    public  List<orderanditem> orderById(JSONObject orderinfo){
        return ordermapper.orderById(orderinfo);
    }



    //    确认付款修改订单为待发货
    @Override
    public boolean updateToWaitItem(JSONObject orderinfo){
        return ordermapper.updateToWaitItem(orderinfo);
    }

    //用户删除未付款的
    @Override
    public boolean delNoPay(JSONObject orderinfo){
        return ordermapper.delNoPay(orderinfo);
    }

    // 提交交易快照完成交货
    @Override
    public boolean updateToInRent(JSONObject orderinfo){
        return ordermapper.updateToInRent(orderinfo);
    }

    //    提交租赁中快照
    @Override
    public boolean updatePic(JSONObject orderinfo){
        return ordermapper.updatePic(orderinfo);
    }

    //续租修改订单信息
    @Override
    public boolean rentnew(JSONObject orderinfo){
        return ordermapper.rentnew(orderinfo);
    }


    //删除快照
    @Override
    public boolean delRentPic(JSONObject orderinfo){
        return ordermapper.delRentPic(orderinfo);
    }

    //归还物品
    @Override
    public boolean backItemTime(JSONObject orderinfo){
        return ordermapper.backItemTime(orderinfo);
    }
    //    归还完毕将物品下架
    @Override
    public boolean itemtodel(JSONObject iteminfo){return ordermapper.itemtodel(iteminfo);}

    //    完成订单付款的对象
    @Override
    public List<outrentuserinfo>outRentUserInfo(JSONObject userinfo){return ordermapper.outRentUserInfo(userinfo);}


    //    订单已评价
    @Override
    public boolean orderForJudge(String orderid){
        return ordermapper.orderForJudge(orderid);
    }

    //查找用户物品出租订单
    @Override
    public List<orderanditem> mineRent(JSONObject openid){
//        System.out.println(openid);
        return ordermapper.mineRent(openid);

    }



    //    查询全部分页订单
    @Override
    public List<order> allOrder(JSONObject pageinfo){return ordermapper.allOrder(pageinfo);}

    //    查询全部订单
    @Override
    public  List<order> allOrders(){return ordermapper.allOrders();}
    //修改订单信息
    @Override
    public boolean updateOrder(JSONObject orderinfo){return ordermapper.updateOrder(orderinfo);}


    //    条件查找
    @Override
    public List<order> searchOrder(JSONObject searchinfo){return ordermapper.searchOrder(searchinfo);}

    //    条件查找
    @Override
    public List<order> searchOrders(JSONObject searchinfo){return ordermapper.searchOrders(searchinfo);}

}
